﻿$(function () {
    $("#album img").click(function () {
        $("#cover img").attr("src", this.src);
        $("#cover a").attr("href", this.src.replace(/\/s_(.*)/ig, "/$1"));
        $("#album img").css("background-color", "#fff");
        $(this).css("background-color", "#ff7417");
    });
    $("#cover a").jqzoom({ zoomWidth: 423, zoomHeight: 210, title: false });
    $("#details").tabs();

    // 多图片滚动
    var o_m = $("#album"), o_as = $("#divAlbumShade"), o_l = $("#divLeftBtn"), o_r = $("#divRightBtn");
    var f_ld = function () { o_l.addClass("leftBtnDisabled").attr("disabled", "disabled"); }
    var f_rd = function () { o_r.addClass("rightBtnDisabled").attr("disabled", "disabled"); }
    var f_le = function () { o_l.removeClass("leftBtnDisabled").removeAttr("disabled"); }
    var f_re = function () { o_r.removeClass("rightBtnDisabled").removeAttr("disabled"); }
    o_l.click(function () {
        f_ld(); o_m.animate({ "left": parseInt(o_m.css("left")) + 55 }, 'fast', null, function () {
            f_le(); if (o_m.width() - Math.abs(parseInt(o_m.css("left"))) > o_as.width() + 5) { f_re(); }
            if (parseInt(o_m.css("left")) >= 0) { f_ld(); }
        });
    });
    o_r.click(function () {
        f_rd(); o_m.animate({ "left": parseInt(o_m.css("left")) - 55 }, 'fast', null, function () {
            f_re(); if (o_m.width() - Math.abs(parseInt(o_m.css("left"))) <= o_as.width() + 5) { f_rd(); }
            if (parseInt(o_m.css("left")) < 0) { f_le(); }
        });
    });
    f_ld(); if (o_m.width() <= o_as.width()) { f_rd(); }
});